package edu.ncsu.helloandroid;

import java.util.HashMap;

/**
 * Keep track of relevant state of play
 * @author Matthew Marum
 *
 */
public class FGCGameState {
	
	private static HashMap<Integer, FGCGameState> states = new HashMap<Integer, FGCGameState>();
	
	private boolean isPlaying;
	private int[] scores;
	private int currentHole;
	private boolean[] completed;
	private int throwCount = 0;
	private int playerPos = 0;
	public final static int LAST_HOLE = 3;
//	public final static int LAST_HOLE = 18;  Don't feel like encoding all 18 holes.. not necessary for evaluation either.
	
	private FGCGameState(){
		isPlaying = false;
		scores = new int[18];
		completed = new boolean[18];
		currentHole=1;
		
	}
	
	public static FGCGameState getGameState(int taskId){
		FGCGameState state = states.get(taskId);
		if(state == null){
			state = new FGCGameState();
			states.put(taskId, state);
		}
		return state;
	}
	
	public static void purgeGameState(int taskId){
		states.remove(taskId);
	}
	
	public boolean isPlaying() {
		return isPlaying;
	}
	
	public void setPlaying(boolean isPlaying) {
		this.isPlaying = isPlaying;
	}
	
	public int[] getScores() {
		return scores;
	}
	
	public boolean isHoleComplete(int hole){
		return completed[hole-1];
	}

	public void completeCurrentHole() {
		completed[this.currentHole-1] = true;
	}
	
	public void setCurrentHole(int currentHole) {
		this.currentHole = currentHole;
	}

	public int getCurrentHole() {
		return currentHole;
	}

	public int discThrown() {
		return ++throwCount;
	}

	public int getThrowCount() {
		return throwCount;
	}

	public int playerMoved(){
		return ++playerPos;
	}

	public int getPlayerPos() {
		return playerPos;
	}
	
	
	

}
